package thread;

/**
 * @Author: hujian
 * @Date: 2019/9/5 14:08
 * @Description:  一个final域可以根据某些对象有所不同，却又保持恒定不变的特性。
 */
public class Final {
    /**
     * Initialized final
     */
    private final int i = 0;
    /**
     * blank final
     */
    private final int j;
    /**
     * blank final reference
     */
    private final Poppet p;

    public Final() {
        j = 1;
        p = new Poppet(1);
    }

    public Final(int x) {
        j = x;
        p = new Poppet(x);
    }

    public static void main(String[] args) {
        Final b1 = new Final();
        Final b2 = new Final(47);
        System.out.println(b1.i);
        System.out.println("b1.j=" + b1.j + "\t\t b1.p.i=" + b1.p.getI());
        System.out.println("b2.j=" + b2.j + "\t\t b2.p.i=" + b2.p.getI());
    }

    class Poppet {
        private int i;

        public Poppet(int i) {
            this.i = i;
        }
        public int getI() {
            return i;
        }
        public void setI(int i) {
            this.i = i;
        }
    }
}
